<%@page contentType="text/html;charset=UTF-8"%>
<%@include file="../common/common.jsp"%>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>红包发放列表</title>
	<link href="${ctx}/resources/css/bootstrap/dashboard.css" rel="stylesheet">
	<link href="${ctx}/resources/css/bootstrap/bootstrap.min.css" rel="stylesheet">
	<link href="${ctx}/resources/font-awesome/css/font-awesome.min.css" rel="stylesheet">
	<script type="text/javascript" src="${ctx}/resources/js/highcharts/jquery-1.8.2.min.js"></script>
	<script src="${ctx}/resources/js/monitor/xl-monitor.js"></script>
	<style type="text/css">
		${demo.css}
		.col-sm-3{
			width : 33%;
		}
		th{
			background-color: gainsboro;
		}
		td{
			font-size: small;
		}

	</style>

</head>
<body style="padding-top:0px;">
<h2 class="sub-header" style="border-bottom:#FFFFFF"><i class="fa fa-cubes"> </i>
	<span style="font-size: small">
		<form method="get" action="${ctx}/hb/list">
			<label style="font-size: 24px;">红包发放列表</label>
			<span style="margin-left: 10px;"><label>昵称：</label><input type="text" id="nickName" name="nickName" value="${filter.nickName}"/></span>
			<span><label>时间：</label><input type="text" id="startDate" name="startDate" value="${filter.startDate}"/><label>━</label><input type="text" id="endDate" name="endDate" value="${filter.endDate}"/></span>
			<span style="margin-left: 10px;"><label>状态：</label>
				<select name="status">
					<option value="">-</option>
					<option value="1"  <c:if test="${filter.status==1}">selected</c:if> >发放中</option>
					<option value="2"  <c:if test="${filter.status==2}">selected</c:if> >已发放待领取</option>
					<option value="3"  <c:if test="${filter.status==3}">selected</c:if> >发放失败</option>
					<option value="4"  <c:if test="${filter.status==4}">selected</c:if> >已领取</option>
					<option value="5"  <c:if test="${filter.status==5}">selected</c:if> >已退款</option>
					<option value="6"  <c:if test="${filter.status==6}">selected</c:if> >重新发放中</option>
				</select>
			</span>
			<input id="pageSize" name="pageSize" value="${filter.pageSize}" type="hidden"/>
			<input id="pageIndex" name="pageIndex" value="${filter.pageIndex}" type="hidden"/>
			<input type="submit" value="查询"/>

			<a href="${ctx}/hb/list?status=3">失败记录</a>
			<a href="${ctx}/hb/list">全部</a>
			<span style="margin-left: 10px;">(记录:${page.total}</span>
			<span style="margin-left: 5px;">发放金额:<font color="red">${sumVo.totalAmount / 100}</font>元</span>
			<span style="margin-left: 5px;">退款金额:${sumVo.refundAmount / 100}元)</span>
		</form>

	</span>
</h2>
<div class="table-responsive">
	<table class="table table-striped table-hover" border="1">
		<thead>
		<tr>
			<th>#序号</th>
			<th>code</th>
			<th>发送人</th>
			<th>红包数量</th>
			<th>红包金额</th>
			<th>昵称</th>
			<th>openId</th>
			<th>wishing</th>
			<th>actName</th>
			<th>remark</th>
			<th>退款金额</th>
			<th>领取金额</th>
			<th>说明</th>
			<th>状态</th>
			<th>操作</th>
			<th>createTime</th>
			<th>updateTime</th>
		</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.content}" var="hb" varStatus="hbStatus">
			<tr>
				<td>${hbStatus.index + 1}</td>
				<td><span class="glyphicon glyphicon-sort-by-attributes">${hb.hbCode}</span></td>
				<td>${hb.sendName}</td>
				<td>${hb.totalNum}&nbsp;</td>
				<td>${hb.totalAmount/100}元&nbsp;</td>
				<td>${hb.nickName}&nbsp;</td>
				<td>${hb.openid}&nbsp;</td>
				<td>${hb.wishing}&nbsp;</td>
				<td>${hb.actName}&nbsp;</td>
				<td>${hb.remark}&nbsp;</td>
				<td>${hb.refundAmount / 100}元&nbsp;</td>
				<td>${hb.amount / 100}元&nbsp;</td>
				<td>${hb.reason}&nbsp;</td>
				<c:choose>
					<c:when test="${hb.status==1}">
						<td><span class="label label-info" style="background-color: chartreuse">发送中&nbsp;</span></td>
					</c:when>
					<c:when test="${hb.status==2}">
						<td><span class="label label-info">已发放待领取&nbsp;</span></td>
					</c:when>
					<c:when test="${hb.status==3}">
						<td><span class="label label-info" style="background-color: red">发放失败&nbsp;</span></td>
					</c:when>
					<c:when test="${hb.status==4}">
						<td><span class="label label-info">已领取&nbsp;</span></td>
					</c:when>
					<c:when test="${hb.status==5}">
						<td><span class="label label-info">已退款&nbsp;</span></td>
					</c:when>
					<c:when test="${hb.status==6}">
						<td><span class="label label-info">重新发放中&nbsp;</span></td>
					</c:when>
					<c:otherwise>
						<td><span class="label label-info">未知&nbsp;</span></td>
					</c:otherwise>
				</c:choose>
				<td>
				<c:choose>
					<c:when test="${hb.status==3}">
						<input type="button" value="重新发放" onclick="doReSend('${hb.hbCode}');"/>
					</c:when>
					<c:when test="${hb.status==4}">
						&nbsp;
					</c:when>
					<c:when test="${hb.status==5}">
						&nbsp;
					</c:when>
					<c:otherwise>
						<input type="button" value="刷新状态" onclick="doRefresh('${hb.hbCode}');"/>
					</c:otherwise>
				</c:choose>
				</td>
				<td>${hb.createAt}&nbsp;</td>
				<td>${hb.updateAt}&nbsp;</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
</div>
<div style="padding-top: 10px;">
	<span style="font-size: small;">状态说明:
		<span style="margin: 2px;">发送中--未提交到微信;</span>
		<span style="margin: 2px;">已发放待领取--提交到微信;</span>
	    <span style="margin: 2px;">发放失败--提交到微信,但是出错了;</span>
		<span style="margin: 2px;">重新发放中--重新提交到微信;</span>
		<span style="margin: 2px;">已领取--用户已经领了红包;</span>
		<span style="margin: 2px;">已退款--超过72小时未领的红包;</span>
	</span>
</div>
	<form id="hbForm" method="post" action="${ctx}/hb/doSendHb">
		<input id="hbcode" name="hbcode" type="hidden"/>
		<input id="pageSize" name="pageSize" value="${filter.pageSize}" type="hidden"/>
		<input id="pageIndex" name="pageIndex" value="${filter.pageIndex}" type="hidden"/>
		<input id="status" name="status" value="${filter.status}" type="hidden"/>
		<input id="nickName" name="nickName" value="${filter.nickName}" type="hidden"/>
		<input id="startDate" name="startDate" value="${filter.startDate}" type="hidden"/>
		<input id="endDate" name="startDate" value="${filter.endDate}" type="hidden"/>
	</form>
</body>
<script language="javascript">
	/**
	*
	* @param hbcode
	 */
	function doReSend(hbcode){
		document.getElementById('hbcode').value=hbcode;
		document.getElementById('hbForm').action='${ctx}/hb/doSendHb';
		document.getElementById('hbForm').submit();
	}
	function doRefresh(hbcode){
		document.getElementById('hbcode').value=hbcode;
		document.getElementById('hbForm').action='${ctx}/hb/refresh';
		document.getElementById('hbForm').submit();
	}
</script>
</html>
